package demo.day08.work_Bank;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/7/26-07-26-19:27
 * @Description：demo.day08.work_Bank
 */
public class CheckingAccount extends Account{
    double overdraft;

    public CheckingAccount(Double balance) {
        super(balance);
    }

    public CheckingAccount(Double balance, double overdraft) {
        super(balance);
        this.overdraft = overdraft;
    }

    @Override
    public boolean withdraw(double amount){
        if(amount <= super.balance){
            System.out.println("成功取款" + amount + "元！");
            balance = balance - amount;
        }else if(amount <=(super.balance + overdraft)){
            System.out.println("温馨提示：当前你已透支：" + (amount-super.balance));
            overdraft = overdraft - (amount-balance);
            super.balance = 0;
        }else{
            System.out.println("取款额度"+ amount +"已超过能取款金额，取款失败！");
            return false;
        }
        return true;
    }

    public double getOverdraft() {
        return overdraft;
    }
}
